package serveur;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import serveur.CpuImpl;
import shared.Memory;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author ju
 */
public class MemoryImpl extends UnicastRemoteObject implements Memory {


    private static MemoryImpl instance;
    private static Object mutex= new Object();
    private int free;
    private int used;
    private int total;

    private MemoryImpl() throws RemoteException{
        
        this.free = 100;
        this.used = 100;
        this.total = 200;
    }
    
    public static MemoryImpl getInstance() throws RemoteException{
        if (null == instance) { // Premier appel
            synchronized (mutex) {
                if (null == instance) {
                    instance = new MemoryImpl();
                }
            }
        }
        return instance;
    }
    
    private MemoryImpl(int free, int used, int total) throws RemoteException {
        this.free = free;
        this.used = used;
        this.total = total;
    }

    @Override
    public String toString() {
        return super.toString(); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public int getFree() {
        return free;
    }

    
    public void setFree(int free) {
        this.free = free;
    }

    @Override
    public int getUsed() {
        return used;
    }

    
    public void setUsed(int used) {
        this.used = used;
    }

    
    public int getTotal() {
        return total;
    }

    
    public void setTotal(int total) {
        this.total = total;
    }
    
    
    
}
